﻿using System.Collections.Generic;
using Orchard.Environment.Extensions;
using Orchard.Security.Permissions;

namespace FruitCake.ContactPage
{
    [OrchardFeature("FruitCake.ContactPage")]
    public class Permissions : IPermissionProvider
    {
        public static readonly Permission CreateContactPage = new Permission { Description = "Create contact page", Name = "CreateContactPage" };
        public static readonly Permission ManageContactRequests = new Permission { Description = "Manage contact requests", Name = "ManageContactRequests" };
        public static readonly Permission SendContactRequest = new Permission { Description = "Send contact request", Name = "SendContactRequest" };

        public Orchard.Environment.Extensions.Models.Feature Feature { get; set; }

        public IEnumerable<PermissionStereotype> GetDefaultStereotypes()
        {
            return new[] {
                new PermissionStereotype {
                    Name = "Administrator",
                    Permissions = new[] {CreateContactPage, ManageContactRequests, SendContactRequest}
                },
                new PermissionStereotype {
                    Name = "Anonymous",
                    Permissions = new[] {SendContactRequest}
                },
                new PermissionStereotype {
                    Name = "Authenticated",
                    Permissions = new[] {SendContactRequest}
                },
                new PermissionStereotype {
                    Name = "Editor",
                    Permissions = new[] {SendContactRequest}
                },
                new PermissionStereotype {
                    Name = "Moderator",
                    Permissions = new[] {ManageContactRequests, SendContactRequest}
                },
                new PermissionStereotype {
                    Name = "Author",
                    Permissions = new[] {SendContactRequest}
                },
                new PermissionStereotype {
                    Name = "Contributor",
                    Permissions = new[] {SendContactRequest}
                },
            };
        }

        public IEnumerable<Permission> GetPermissions()
        {
            return new[] { CreateContactPage, ManageContactRequests, SendContactRequest };
        }
    }
}